// vite.config.js
import { defineConfig } from 'vite';
import vue from '@vitejs/plugin-vue';

import Components from 'unplugin-vue-components/vite';
import { AntDesignVueResolver } from 'unplugin-vue-components/resolvers';

const path = require('path')

// https://vitejs.dev/config/
export default defineConfig({
    plugins: [
        vue(),
        Components({
            resolvers: [
              AntDesignVueResolver({
                importStyle: false, // css in js
              }),
            ],
          }),
    ],
    resolve: {
      alias: {
        '@': path.resolve(__dirname, 'src')
      }
    },
    server:{
      proxy:{
          //将以/api开头的请求代理到目标服务器
          '/api/':{
            target:'http://localhost:3000/',
            changeOrigin:true,
            rewrite:(path) => path.replace(/^\/api/,'')
          }
      }
    }
});